import 'package:flutter/material.dart';

void main() => runApp(IconFontApp());

class IconFontApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '自定义字体图标示例',
      theme: ThemeData(primarySwatch: Colors.blue),
      home: IconFontDemo(),
    );
  }
}

// 自定义图标类
class MyIcons {
  // book 图标
  static const IconData book = IconData(
    0xe614,
    fontFamily: 'myIcon',
    matchTextDirection: true,
  );
  // 微信图标
  static const IconData wechat = IconData(
    0xe856,
    fontFamily: 'myIcon',
    matchTextDirection: true,
  );
}

class IconFontDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('自定义字体图标示例')),
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Icon(MyIcons.book, color: Colors.purple, size: 48),
            SizedBox(width: 30),
            Icon(MyIcons.wechat, color: Colors.green, size: 48),
          ],
        ),
      ),
    );
  }
}
